from rest_framework import permissions
from rest_framework.permissions import BasePermission

class IsChefOwner(permissions.BasePermission):
    """
    检查当前用户是否是菜品所属厨师
    """
    def has_object_permission(self, request, view, obj):
        # 假设厨师模型有user字段关联到User模型
        return obj.chef.user == request.user
    
class IsAdminUser(BasePermission):
    """
    自定义管理员权限类
    只允许管理员用户访问
    """
    def has_permission(self, request, view):
        return bool(request.user and request.user.is_staff)